<?PHP
/* Web Statistics and Analytics Console (PHP)
 *  login.php
 *  Author: Trevor Bidyk
 *  Created: January 1, 2000
 *  Last modified: April 2, 2011
 *   (C) Us 2011
 *   Uses Simple PHP Framework, licensed under the FreeBSD license.
 *    View license in ./include/LICENSE.
 *   All rights reserved.
 */
    require 'includes/master.inc.php';

    if($Auth->loggedIn()) redirect(WEB_ROOT);

    if(!empty($_POST['username']))
    {
        if($Auth->login($_POST['username'], $_POST['password']))
        {
            if(isset($_REQUEST['r']) && strlen($_REQUEST['r']) > 0)
                redirect($_REQUEST['r']);
            else
                redirect(WEB_ROOT);
        }
        else
            $Error->add('username', "We're sorry, you have entered an incorrect username and password. Please try again.");
    }

    // Clean the submitted username before redisplaying it.
    $username = isset($_POST['username']) ? htmlspecialchars($_POST['username']) : '';
?>
﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
	<title>Web Statistics and Analytics Console</title>
	<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div id="aac-header">
		<div id="interior">
			<div id="title"><span>Web Statistics and Analytics Console</span></div>
			<div id="current-time"><span><?php echo date("H:m F, j Y")?></span></div>
                        <div id="current-user">&nbsp;</div>
		</div>
	</div>
	<div id="content" style="text-align: center">
            <h3>Please login to continue:</h3>
            <span><?php echo $Error; ?></span>
            <br />
            <form action="login.php" method="post"> 
                <span>
                    <label for="username">Username:</label>
                    <input type="text" name="username" value="<?php echo $username;?>" id="username" />
                </span>
                <br />
                <span>
                    <label for="password">Password:</label>
                    <input type="password" name="password" value="" id="password" />
                </span>
                <br />
                <br />
                <input type="submit" name="btnlogin" value="Login" id="btnlogin" />
                <input type="hidden" name="r" value="<?PHP echo htmlspecialchars(@$_REQUEST['r']); ?>" id="r" />
    </form>
	</div>

</body>
</html>